﻿<CodeSnippetTabbed DocLink="https://docs.devexpress.com/Blazor/DevExpress.Blazor.DxContextMenu#bound-mode">
    <CodeSnippetTabPage Text="Razor">@(@"<div style=""@Formatting.GetStyleString()"" @oncontextmenu=""((e) => { ContextMenu.Show(e); } )"" @oncontextmenu:preventDefault>
    <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris sit amet metus vel nisi blandit tincidunt vel efficitur purus.
        Nunc nec turpis tempus, accumsan orci auctor, imperdiet mauris. Fusce id purus magna.</span>
</div>
<DxContextMenu Data=""@MenuItems""
               ItemClick=""((args) => { InvokeAsync(StateHasChanged); })""
               TextExpression=""(item => (item as TextFormattingMenuItem).Text)""
               ClickExpression=""(item => (item as TextFormattingMenuItem).Click)""
               ChildrenExpression=""(item => (item as TextFormattingMenuItem).Children)""
               BeginGroupExpression=""(item => (item as TextFormattingMenuItem).BeginGroup)""
               IconUrlExpression=""(item => (item as TextFormattingMenuItem).IconUrl)""
               @ref=""@ContextMenu"">
</DxContextMenu>

@code {
    List<TextFormattingMenuItem> menuItems;

    DxContextMenu ContextMenu { get; set; }
    TextFormatting Formatting { get; set; } = new TextFormatting();
    List<TextFormattingMenuItem> MenuItems {
        get {
            if (menuItems == null) {
                menuItems = new List<TextFormattingMenuItem>() {
                    new TextFormattingParentMenuItem(Formatting, ""Font"", new List<TextFormattingMenuItem>() {
                        new FontFamilyMenuItem(Formatting, ""Times New Roman"", ""Times New Roman""),
                        new FontFamilyMenuItem(Formatting, ""Tahoma"", ""Tahoma""),
                        new FontFamilyMenuItem(Formatting, ""Verdana"", ""Verdana""),
                        new FontFamilyMenuItem(Formatting, ""Arial"", ""Arial""),
                        new FontFamilyMenuItem(Formatting, ""MS Sans Serif"", ""MS Sans Serif""),
                        new FontFamilyMenuItem(Formatting, ""Courier"", ""Courier""),
                        new FontFamilyMenuItem(Formatting, ""Segoe UI"", ""Segoe UI""),
                        new FontFamilyMenuItem(Formatting, ""Default"", null) { BeginGroup = true }
                    }),
                    new TextFormattingParentMenuItem(Formatting, ""Size"", new List<TextFormattingMenuItem>() {
                        new FontSizeMenuItem(Formatting, ""8pt"", 8),
                        new FontSizeMenuItem(Formatting, ""10pt"", 10),
                        new FontSizeMenuItem(Formatting, ""12pt"", 12),
                        new FontSizeMenuItem(Formatting, ""14pt"", 14),
                        new FontSizeMenuItem(Formatting, ""18pt"", 18),
                        new FontSizeMenuItem(Formatting, ""24pt"", 24),
                        new FontSizeMenuItem(Formatting, ""36pt"", 36)
                    }),
                    new TextFormattingParentMenuItem(Formatting, ""Style"", new List<TextFormattingMenuItem>() {
                        new TextDecorationMenuItem(Formatting, ""Bold"", ""Bold""),
                        new TextDecorationMenuItem(Formatting, ""Italic"", ""Italic""),
                        new TextDecorationMenuItem(Formatting, ""Underline"", ""Underline""),
                        new TextDecorationMenuItem(Formatting, ""Overline"", ""Overline""),
                        new TextDecorationMenuItem(Formatting, ""Strikethrough"", ""Strikethrough"")
                    }),
                    new ClearFormattingMenuItem(Formatting) { BeginGroup = true }
                };
            }
            return menuItems;
        }
    }
}")
    </CodeSnippetTabPage>
    <CodeSnippetTabPage Text="TextFormatting" Language="csharp">
<CodeSnippet_TextFormatting />
    </CodeSnippetTabPage>
    <CodeSnippetTabPage Text="Menu Items" Language="csharp">
<CodeSnippet_TextFormatting_MenuItems />
    </CodeSnippetTabPage>
</CodeSnippetTabbed>
